package org.example.sprojcet.entitys;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import org.example.sprojcet.comment.Valida;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@TableName("sys_user")
@Getter
@Setter
public class User implements Serializable {
    private static final long serialVersionUID = 1L;
    //id
    private Long id;
    //名字
    @NotNull(message = "名字不能为空",groups ={Valida.Create.class} )
    private String name;
    //电话
    @NotNull(message = "电话号码不能为空",groups ={Valida.Create.class} )
    private String phone;
    //密码
    @NotBlank(message = "密码不能为空",groups ={Valida.Create.class} )
    @Size(min = 6 ,max = 10,message = "密码长度需要6-10位",groups ={Valida.Create.class} )
    private String password;
    //简介
    private String remark;
    //状态
    private Integer status;
    //提交时间
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime submitTime;

    public Object getPhone(User user) {
        return user.getPhone();
    }
}
